.TH std::basic_string_view::front 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::basic_string_view::front \- std::basic_string_view::front

.SH Synopsis
   constexpr const_reference front() const;  \fI(since C++17)\fP

   Returns reference to the first character in the view. The behavior is undefined if
   empty() == true.

.SH Parameters

   \fI(none)\fP

.SH Return value

   Reference to the first character, equivalent to operator[]\fB(0)\fP.

.SH Complexity

   Constant.

.SH Example


// Run this code

 #include <iostream>
 #include <string_view>

 int main()
 {
     for (std::string_view str{"ABCDEF"}; !str.empty(); str.remove_prefix(1))
         std::cout << str.front() << ' ' << str << '\\n';
 }

.SH Output:

 A ABCDEF
 B BCDEF
 C CDEF
 D DEF
 E EF
 F F

.SH See also

   back  accesses the last character
         \fI(public member function)\fP
   empty checks whether the view is empty
         \fI(public member function)\fP
   front accesses the first character
   (DR*) \fI(public member function of std::basic_string<CharT,Traits,Allocator>)\fP
